package com.yn.admin.zy;

import com.yn.common.page.BasePage;
import com.yn.common.request.sc.PageParamRequest;
import com.yn.common.request.zyorder.ZyServiceConfigRequest;
import com.yn.common.request.zyorder.ZyServiceConfigSearch;
import com.yn.common.request.zyorder.ZyServiceRegionPriceRequest;
import com.yn.common.request.zyorder.ZyServiceRegionPriceSearch;
import com.yn.common.response.sc.BaseResult;
import com.yn.common.response.zyorder.ZyServiceConfigResponse;
import com.yn.common.response.zyorder.ZyServiceRegionPriceResponse;
import com.yn.service.service.ZyServiceConfigService;
import com.yn.service.service.ZyServiceRegionPriceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("api/zy/service/config")
@Api(tags = "转运服务配置相关接口")
@Slf4j
public class ZyServiceConfigController {

    @Autowired
    private ZyServiceConfigService zyServiceConfigService;

    /**
     * 服务项区域配置价格新增你修改
     */
    @ApiOperation(value = "服务项配置新增修改")
    @PostMapping("/saveOrUpdateServiceRegionPrice")
    public BaseResult<String> saveOrUpdateServiceConfig(@RequestBody @Validated ZyServiceConfigRequest zyServiceConfigRequest) {
        zyServiceConfigService.saveOrUpdateServiceConfig(zyServiceConfigRequest);
        return BaseResult.success();
    }

    /**
     * 服务项区域配置价格详情
     */
    @ApiOperation(value = "服务项配置详情")
    @GetMapping("/getServiceConfigById")
    public BaseResult<ZyServiceConfigResponse> getServiceConfigById(Integer id) {
        ZyServiceConfigResponse response = zyServiceConfigService.getServiceConfigById(id);
        return BaseResult.success(response);
    }


    /**
     * 删除服务项区域配置价格
     */
    @DeleteMapping("/del")
    @ApiOperation(value = "删除服务项配置")
    public BaseResult<String> del(Integer id) {
        log.info("删除服务项区域配置价格入参id：{}", id);
        zyServiceConfigService.del(id);
        return BaseResult.success();
    }

    /**
     * 区域配置列表查询
     *
     * @param serviceConfigSearch
     * @param pageParamRequest
     * @return
     */
    @GetMapping("/listServiceRegionPriceList")
    @ApiOperation(value = "服务项配置分页查询")
    BaseResult<BasePage<ZyServiceConfigResponse>> listServiceRegionPriceList(ZyServiceConfigSearch serviceConfigSearch,
                                                                                  PageParamRequest pageParamRequest) {
        BasePage<ZyServiceConfigResponse> responseBasePage =
                zyServiceConfigService.listServiceConfigByServiceTypeList(serviceConfigSearch, pageParamRequest);
        return BaseResult.success(responseBasePage);
    }


}
